let http=require('http');
let mysql=require('mysql');
let querystring=require('querystring');
http.createServer((req,res)=>{
    let connection = mysql.createConnection({
        host     : '47.97.99.197',
        user     : 'root',
        password : 'root',
        port: '3306',
        database: 'wangjun'
    });
    connection.connect();
    var  addSql = 'INSERT INTO websites(Id,name,url,alexa,country) VALUES(0,?,?,?,?)';
    var  addSqlParams = ['汪骏', 'https://c.runoob.com','23453', 'CN'];
//增
    connection.query(addSql,addSqlParams,function (err, result) {
        if(err){
            console.log('[INSERT ERROR] - ',err.message);
            return;
        }

        console.log('--------------------------INSERT----------------------------');
        //console.log('INSERT ID:',result.insertId);
        console.log('INSERT ID:',result);
        console.log('-----------------------------------------------------------------\n\n');
    });
    connection.end();
    res.end('添加成功')
}).listen(8080,()=>{
    console.log('server is run on 127.0.0.1:8080')
});
